package com.lhn.tankGame3;

/**
 * @author lhn
 * @date 2024-07-24 18:00
 * 自己的坦克
 */

public class Hero extends Tank {

    //定义一个shoot对象，表示一个射击线程
    Shoot shoot = null;

    public Hero(int x, int y, int direction) {
        super(x, y, direction);
    }

    public Hero(int x, int y, int direction, int speed) {
        super(x, y, direction, speed);
    }

    //射击
    public void shootEnemy() {
        switch (
                getDirection()
        ) {
            case 0:
                shoot = new Shoot(getX() + 20, getY(), getDirection());
                break;
            case 1:
                shoot = new Shoot(getX() + 60, getY() + 20, getDirection());
                break;
            case 2:
                shoot = new Shoot(getX() + 20, getY() + 60, getDirection());
                break;
            case 3:
                shoot = new Shoot(getX() + 60, getY() + 20, getDirection());
                break;
        }

        Thread thread = new Thread(shoot);
        thread.start();
    }
}
